package com.qidianit.mes.production.controller;

import com.qidianit.common.pojo.MESResult;
import com.qidianit.mes.pojo.Workmanship;
import com.qidianit.mes.production.service.WorkmanshipService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author djl
 * @Time 2024/10/19 9:57
 */
@RestController
@RequestMapping("/workmanship")
@CrossOrigin
public class WorkmanshipController {
    @Autowired
    private WorkmanshipService workmanshipService;
    @GetMapping("/list")
    public MESResult list(String workmanshipRouteId,String workmanshipName,Integer workmanshipStatus,
                          @RequestParam(defaultValue = "1")int page,
                          @RequestParam(defaultValue = "10")int limit) {
        return workmanshipService.list(workmanshipRouteId,workmanshipName,workmanshipStatus,page,limit);
    }
    @PostMapping("/add")
    public MESResult addNewWorkmanship(@RequestBody Workmanship workmanship){
        return workmanshipService.addNewWorkmanship(workmanship);
    }
    @DeleteMapping("/delete")
    public MESResult deleteWorkmanship(String workmanshipRouteId){
        return workmanshipService.deleteWorkmanship(workmanshipRouteId);
    }
    @PostMapping("/edit")
    public MESResult editWorkmanship(@RequestBody Workmanship workmanship){
        return workmanshipService.editWorkmanship(workmanship);
    }
    @DeleteMapping("/reDelete")
    public MESResult reDelete(String[] workmanshipRouteIds){
        System.out.println("controller");
        return workmanshipService.reDelete(workmanshipRouteIds);
    }
    @GetMapping("/showByWorkmanshipId")
    public MESResult showByWorkmanshipId(Integer workmanshipId){
        return workmanshipService.showByWorkmanshipId(workmanshipId);
    }
}
